<template>
	<view>
		<view style="width: 750upx;height: 176upx;">
			<image src="../../static/shangmen/bj.png" style="width: 750upx;height: 176upx;position: absolute;"></image>
			<view style="display: flex;" @click="shangyibu">
				<view style="position: absolute;display: flex;margin-left: 20upx;line-height: 176upx;">
					<image src="../../static/shangmen/29.png" style="width: 38upx;height: 38upx;margin-top: 72upx;" ></image>
				</view>
				<view style="width: 750upx;height: 176upx;text-align: center;font-size: 36upx;line-height: 176upx;position: absolute;z-index: 1;color: #fff;">选择汽车品牌</view>
			</view>
		</view>
		<view >
			<uni-indexed-list :options="list" :showSelect="false" @click="bindClick"></uni-indexed-list>
		</view>
	</view>
</template>

<script>
	import airport from '../../common/airport.js'
	export default {
		components: {},
		data() {
			return {
				// list: airport.list
				list: [],
				lists:[]
			}
		},
		onLoad() {
			this.car_brand_api()
		},
		methods: {
			car_brand_api(id) {
				var that = this
				that.$request(that.$Api.car_brand_api, {
					access_token:uni.getStorageSync('access_token')
				},"POST").then(res => {
					console.log('res.data.data',res.data.data)
					that.lists = res.data.data
					var data = []
					for( let i=0;i<res.data.data.length;i++ ) {
						var jrr = []
						for(let o=0;o<res.data.data[i].data.length;o++ ) {
							jrr.push(res.data.data[i].data[o].name)
						}
						var arr = {
							letter:res.data.data[i].letter,
							data:jrr
						}
						data.push(arr)
					}
					that.list = data
					console.log('that.list',that.list)
				})
			},
			shangyibu() {
				uni.navigateBack()
			},
			bindClick(e) {
				// var data = e
				console.log('data====', e)
				console.log('data', e.item.itemIndex)
				for( let i=0;i<this.lists.length;i++ ) {
					if(e.item.key === this.lists[i].letter ) {
						for(let j=0;j<this.lists[i].data.length;j++) {
							if(e.item.name === this.lists[i].data[j].name ) {
								console.log('id------',this.lists[i].data[j].id)
								console.log('name------',this.lists[i].data[j].name)
								var id = this.lists[i].data[j].id
								var name = this.lists[i].data[j].name
							}
						}
					}
				}
				// console.log('点击item，返回数据' + JSON.stringify(e))
				const jsonObj = e
				const valuesArr = Object.values(jsonObj);
				console.log(valuesArr);  // ["张三", 18, "男"]
				uni.navigateTo({
					url:'../modelss/modelss?id='+id+'&name='+name
				})
			}
		}
	}
</script>

<style lang="less">
</style>
